\subsection{Cones over diagrams}
To formally define limits and colimits, we first need to define more precisely what is meant by a diagram in a category.
\begin{definition}
    Let \( J \) be a category, which will almost always be small, and often finite.
    A \emph{diagram} of shape \( J \) in a category \( \mathcal C \) is a functor \( D : J \to \mathcal C \).
\end{definition}
We call the objects \( D(j) \) the \emph{vertices} of the diagram, and the morphisms \( D(\alpha) \) the \emph{edges} of the diagram.
\begin{example}
    Let \( J \) be the finite category
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJcXGJ1bGxldCJdLFsxLDAsIlxcYnVsbGV0Il0sWzEsMSwiXFxidWxsZXQiXSxbMCwxLCJcXGJ1bGxldCJdLFswLDFdLFsxLDJdLFswLDJdLFswLDNdLFszLDJdXQ==
\[\begin{tikzcd}
	\bullet & \bullet \\
	\bullet & \bullet
	\arrow[from=1-1, to=1-2]
	\arrow[from=1-2, to=2-2]
	\arrow[from=1-1, to=2-2]
	\arrow[from=1-1, to=2-1]
	\arrow[from=2-1, to=2-2]
\end{tikzcd}\]
    A diagram of shape \( J \) in \( \mathcal C \) is exactly a commutative square in \( \mathcal C \).
    The diagonal arrow is required to make \( J \) into a category.
\end{example}
\begin{example}
    Let \( J \) be the finite category
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJcXGJ1bGxldCJdLFsxLDAsIlxcYnVsbGV0Il0sWzEsMSwiXFxidWxsZXQiXSxbMCwxLCJcXGJ1bGxldCJdLFswLDFdLFsxLDJdLFswLDNdLFszLDJdLFswLDIsIiIsMSx7Im9mZnNldCI6LTJ9XSxbMCwyLCIiLDEseyJvZmZzZXQiOjJ9XV0=
\[\begin{tikzcd}
	\bullet & \bullet \\
	\bullet & \bullet
	\arrow[from=1-1, to=1-2]
	\arrow[from=1-2, to=2-2]
	\arrow[from=1-1, to=2-1]
	\arrow[from=2-1, to=2-2]
	\arrow[shift left=1, from=1-1, to=2-2]
	\arrow[shift right=1, from=1-1, to=2-2]
\end{tikzcd}\]
    Then a diagram of shape \( J \) in \( \mathcal C \) is a square of objects in \( \mathcal C \) whose morphisms may or may not commute.
\end{example}
\begin{definition}
    Let \( D \) be a diagram of shape \( J \) in \( \mathcal C \).
    A \emph{cone over \( D \)} consists of an object \( C \in \ob \mathcal C \) called the \emph{apex} of the cone, together with morphisms \( \lambda_j : A \to D(j) \) called the \emph{legs} of the cone, such that all triangles of the following form commute.
    % https://q.uiver.app/#q=WzAsMyxbMSwwLCJBIl0sWzAsMSwiRChqKSJdLFsyLDEsIkQoaicpIl0sWzAsMSwiXFxsYW1iZGFfaiIsMl0sWzEsMiwiRChcXGFscGhhKSIsMl0sWzAsMiwiXFxsYW1iZGFfe2onfSJdXQ==
\[\begin{tikzcd}
	& A \\
	{D(j)} && {D(j')}
	\arrow["{\lambda_j}"', from=1-2, to=2-1]
	\arrow["{D(\alpha)}"', from=2-1, to=2-3]
	\arrow["{\lambda_{j'}}", from=1-2, to=2-3]
\end{tikzcd}\]
\end{definition}
We can define the notion of a morphism between cones.
\begin{definition}
    Let \( (A, \lambda_j), (B, \mu_j) \) be cones over a diagram \( D \) of shape \( J \) in \( \mathcal C \).
    Then a \emph{morphism of cones} is a morphism \( f : A \to B \) such that all triangles of the following form commute.
    % https://q.uiver.app/#q=WzAsMyxbMCwwLCJBIl0sWzIsMCwiQiJdLFsxLDEsIkQoaikiXSxbMCwxLCJmIl0sWzEsMiwiXFxtdV9qIl0sWzAsMiwiXFxsYW1iZGFfaiIsMl1d
\[\begin{tikzcd}
	A && B \\
	& {D(j)}
	\arrow["f", from=1-1, to=1-3]
	\arrow["{\mu_j}", from=1-3, to=2-2]
	\arrow["{\lambda_j}"', from=1-1, to=2-2]
\end{tikzcd}\]
\end{definition}
This makes the class of cones over a diagram \( D \) into a category, which will be denoted \( \operatorname{Cone}(D) \).
\begin{remark}
    A cone over a diagram \( D \) with apex \( A \) is the same as a natural transformation from the constant diagram \( \Delta A \) to \( D \), as we can expand the commutative triangles into the following form.
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJBIl0sWzEsMCwiQSJdLFsxLDEsIkQoaicpIl0sWzAsMSwiRChqKSJdLFswLDEsIjFfQSJdLFsxLDIsIlxcbGFtYmRhX3tqJ30iXSxbMCwzLCJcXGxhbWJkYV9qIiwyXSxbMywyLCJEKFxcYWxwaGEpIiwyXV0=
\[\begin{tikzcd}
	A & A \\
	{D(j)} & {D(j')}
	\arrow["{1_A}", from=1-1, to=1-2]
	\arrow["{\lambda_{j'}}", from=1-2, to=2-2]
	\arrow["{\lambda_j}"', from=1-1, to=2-1]
	\arrow["{D(\alpha)}"', from=2-1, to=2-2]
\end{tikzcd}\]
    Note that \( \Delta \) is a functor \( \mathcal C \to [J, \mathcal C] \), and thus \( \operatorname{Cone}(D) \) is exactly the comma category \( (\Delta \downarrow D) \).
\end{remark}

\subsection{Limits}
\begin{definition}
    A \emph{limit} for a diagram \( D \) of shape \( J \) in \( \mathcal C \) is a terminal object in the category of cones over \( D \).
    Dually, a \emph{colimit} for \( D \) is an initial object in the category of cones under \( D \).
\end{definition}
A cone under a diagram is often called a \emph{cocone}.
\begin{remark}
    Using the fact that \( \operatorname{Cone}(D) = (\Delta \downarrow D) \) where \( \Delta : \mathcal C \to [J, \mathcal C] \), the category \( \mathcal C \) has limits for all diagrams of shape \( J \) if and only if \( \Delta \) has a right adjoint.
\end{remark}
\begin{example}
    \begin{enumerate}
        \item If \( J \) is the empty category, there is a unique diagram \( D \) of shape \( J \) in any category \( \mathcal C \).
        Thus, a cone over this diagram is just an object in \( \mathcal C \), and morphisms of cones are just morphisms in \( \mathcal C \).
        In particular, \( \operatorname{Cone}(D) \cong \mathcal C \), so a limit for \( D \) is a terminal object in \( \mathcal C \).
        Dually, a colimit of the empty diagram is an initial object.
        \item Let \( J \) be the discrete category with two objects.
        A diagram of shape \( J \) in \( \mathcal C \) is thus a pair of objects.
        A cone over this diagram is a \emph{span}.
        \[\begin{tikzcd}
            & C \\
            A && B
            \arrow[from=1-2, to=2-1]
            \arrow[from=1-2, to=2-3]
        \end{tikzcd}\]
        A limit cone is precisely a categorical product \( A \times B \).
        \[\begin{tikzcd}
            & {A \times B} \\
            A && B
            \arrow["{\pi_1}"', from=1-2, to=2-1]
            \arrow["{\pi_2}", from=1-2, to=2-3]
        \end{tikzcd}\]
        Similarly, the colimit for a pair of objects is a categorical coproduct \( A + B \).
        \item If \( J \) is any discrete category, a diagram of shape \( J \) is a family of objects \( A_j \) in \( \mathcal C \) indexed by the objects of \( J \).
        Limits and colimits over this diagram are products and coproducts of the \( A_j \).
        \item If \( J \) is the category \( \bullet \rightrightarrows \bullet \), a diagram of shape \( J \) is a parallel pair of morphisms \( f, g : A \rightrightarrows B \).
        A cone over such a parallel pair is
        % https://q.uiver.app/#q=WzAsMyxbMSwwLCJDIl0sWzAsMSwiQSJdLFsyLDEsIkIiXSxbMCwxLCJoIiwyXSxbMCwyLCJrIl0sWzEsMiwiZiIsMCx7Im9mZnNldCI6LTJ9XSxbMSwyLCJnIiwyLHsib2Zmc2V0IjoyfV1d
\[\begin{tikzcd}
	& C \\
	A && B
	\arrow["h"', from=1-2, to=2-1]
	\arrow["k", from=1-2, to=2-3]
	\arrow["f", from=2-1, to=2-3]
	\arrow["g"', shift right=2, from=2-1, to=2-3]
\end{tikzcd}\]
        satisfying \( fh = k = gh \).
        Equivalently, it is a morphism \( h : C \to A \) satisfying \( fh = gh \).
        Thus, a limit is an equaliser, and dually, a colimit is a coequaliser.
        \item Let \( J \) be the category
        % https://q.uiver.app/#q=WzAsMyxbMSwwLCJcXGJ1bGxldCJdLFsxLDEsIlxcYnVsbGV0Il0sWzAsMSwiXFxidWxsZXQiXSxbMCwxXSxbMiwxXV0=
\[\begin{tikzcd}
	& \bullet \\
	\bullet & \bullet
	\arrow[from=1-2, to=2-2]
	\arrow[from=2-1, to=2-2]
\end{tikzcd}\]
        A diagram of shape \( J \) is thus a cospan in \( \mathcal C \).
        % https://q.uiver.app/#q=WzAsMyxbMSwwLCJBIl0sWzEsMSwiQyJdLFswLDEsIkIiXSxbMCwxLCJmIl0sWzIsMSwiZyIsMl1d
\[\begin{tikzcd}
	& A \\
	B & C
	\arrow["f", from=1-2, to=2-2]
	\arrow["g"', from=2-1, to=2-2]
\end{tikzcd}\]
        A cone over this diagram is
        % https://q.uiver.app/#q=WzAsNCxbMSwwLCJBIl0sWzEsMSwiQyJdLFswLDEsIkIiXSxbMCwwLCJEIl0sWzAsMSwiZiJdLFsyLDEsImciLDJdLFszLDAsImgiXSxbMywxLCJcXGVsbCIsMl0sWzMsMiwiayIsMl1d
\[\begin{tikzcd}
	D & A \\
	B & C
	\arrow["f", from=1-2, to=2-2]
	\arrow["g"', from=2-1, to=2-2]
	\arrow["h", from=1-1, to=1-2]
	\arrow["\ell"', from=1-1, to=2-2]
	\arrow["k"', from=1-1, to=2-1]
\end{tikzcd}\]
        where \( \ell = fh = gk \) is redundant.
        Thus a cone is a span that completes the commutative square.
        A limit for the cospan is the universal way to complete this commutative square, which is called a \emph{pullback} of \( f \) and \( g \).
        Dually, colimits of spans are called \emph{pushouts}.

        If any category \( \mathcal C \) has binary products and equalisers, we can construct all pullbacks.
        First, we construct the product \( A \times B \), then we form the equaliser of \( f \pi_1, g \pi_2 : A \times B \rightrightarrows C \).
        This yields the pullback.
        \item Let \( M \) be the two-element monoid \( \qty{1, e} \) with \( e^2 = e \).
        A diagram of shape \( M \) in a category \( \mathcal C \) is an object of \( \mathcal C \) equipped with an idempotent endomorphism.
        A cone over this diagram is a morphism \( f : B \to A \) such that \( ef = f \).
        A limit (respectively colimit) is the monic (respectively epic) part of a splitting of \( e \).
        This is because the pair \( (e, 1_A) \) has an equaliser if and only if \( e \) splits.
        % Note that the functor \( F : \mathbf{Set} \to [M, \mathbf{Set}] \) is the constant map \( \Delta \), which explains why the left and right adjoints coincide. % what is 3.2(e)?
        \item Let \( \mathbb N \) be the poset category of the natural numbers.
        A diagram of shape \( \mathbb N \) is a \emph{direct sequence} of objects, which consists of objects \( A_0, A_1, \dots \) and morphisms \( f_i : A_i \to A_{i+1} \).
        A colimit for this diagram is a \emph{direct limit}, which consists of an object \( A_\infty \) and morphisms \( g_i : A_i \to A_\infty \) which are compatible with the \( f_i \).
        Dually, an \emph{inverse sequence} is a diagram of shape \( \mathbb N^\cop \), and a limit for this diagram is called an \emph{inverse limit}.
        For example, an infinite-dimensional CW-complex \( X \) is the direct limit of its \( n \)-dimensional skeletons in \( \mathbf{Top} \).
        The ring of \( p \)-adic integers is the limit of the inverse sequence defined by \( A_n = \faktor{\mathbb Z}{p^n\mathbb Z} \) in \( \mathbf{Rng} \).
    \end{enumerate}
\end{example}
\begin{lemma}
    Let \( \mathcal C \) be a category.
    \begin{enumerate}
        \item If \( \mathcal C \) has equalisers and all small products, then \( \mathcal C \) has all small limits.
        \item If \( \mathcal C \) has equalisers and all finite products, then \( \mathcal C \) has all finite limits.
        \item If \( \mathcal C \) has pullbacks and a terminal object, then \( \mathcal C \) has all finite limits.
    \end{enumerate}
\end{lemma}
Note that the empty product is implicitly included in (i) and (ii).
A terminal object is a product over no factors.
\begin{proof}
    \emph{Parts (i) and (ii).}
    We prove (i) and (ii) in the same way.
    We will first construct the product \( P \) of the \( D(j) \) for each \( j \in \ob J \).
    Then, we will use an equaliser to construct the subobject \( E \) of \( P \) that simultaneously satisfies all of the equations required for \( E \) to be the apex of a cone.
    The fact that we have used an equaliser will show that this is a limit cone.

    Let \( D : J \to \mathcal C \) be a diagram.
    We form the products
    \[ P = \prod_{j \in \ob J} D(j);\quad Q = \prod_{\alpha \in \mor J} D(\cod \alpha) \]
    These are small or finite as required.
    Using the universal property of the product on \( Q \), we have morphisms \( f, g : P \rightrightarrows Q \) defined by
    \[ \pi_\alpha f = \pi_{\cod \alpha} : P \to D(\cod \alpha);\quad \pi_\alpha g = D(\alpha) \pi_{\dom \alpha} : P \to D(\cod \alpha) \]
    For \( \alpha : j \to j' \) in \( D \), these morphisms are represented by
    % https://q.uiver.app/#q=WzAsNyxbNCwwLCJQIl0sWzQsMiwiRChqKSJdLFs2LDIsIkQoaicpIl0sWzYsMCwiUSJdLFswLDAsIlAiXSxbMiwwLCJRIl0sWzIsMiwiRChqJykiXSxbMCwxLCJcXHBpX2oiLDJdLFsxLDIsIkQoXFxhbHBoYSkiLDJdLFszLDIsIlxccGlfXFxhbHBoYSJdLFswLDMsImciLDAseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJkYXNoZWQifX19XSxbNCw1LCJmIiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzUsNiwiXFxwaV9cXGFscGhhIl0sWzQsNiwiXFxwaV97aid9IiwyXV0=
\[\begin{tikzcd}
	P && Q && P && Q \\
	\\
	&& {D(j')} && {D(j)} && {D(j')}
	\arrow["{\pi_j}"', from=1-5, to=3-5]
	\arrow["{D(\alpha)}"', from=3-5, to=3-7]
	\arrow["{\pi_\alpha}", from=1-7, to=3-7]
	\arrow["g", dashed, from=1-5, to=1-7]
	\arrow["f", dashed, from=1-1, to=1-3]
	\arrow["{\pi_\alpha}", from=1-3, to=3-3]
	\arrow["{\pi_{j'}}"', from=1-1, to=3-3]
\end{tikzcd}\]
    Let \( e : E \to P \) be an equaliser for \( f \) and \( g \), and define \( \lambda_j = \pi_j e : E \to D(j) \).
    Then for each \( \alpha : j \to j' \), the following diagram commutes.
    % https://q.uiver.app/#q=WzAsNCxbMSwxLCJQIl0sWzAsMiwiRChqKSJdLFsyLDIsIkQoaicpIl0sWzEsMCwiRSJdLFswLDEsIlxccGlfaiIsMl0sWzEsMiwiRChcXGFscGhhKSIsMl0sWzAsMiwiXFxwaV97aid9Il0sWzMsMCwiZSJdLFszLDIsIlxcbGFtYmRhX3tqJ30iLDAseyJvZmZzZXQiOjEsImN1cnZlIjotMn1dLFszLDEsIlxcbGFtYmRhX2oiLDIseyJjdXJ2ZSI6Mn1dXQ==
\[\begin{tikzcd}
	& E \\
	& P \\
	{D(j)} && {D(j')}
	\arrow["{\pi_j}"', from=2-2, to=3-1]
	\arrow["{D(\alpha)}"', from=3-1, to=3-3]
	\arrow["{\pi_{j'}}", from=2-2, to=3-3]
	\arrow["e", from=1-2, to=2-2]
	\arrow["{\lambda_{j'}}", shift right, curve={height=-12pt}, from=1-2, to=3-3]
	\arrow["{\lambda_j}"', curve={height=12pt}, from=1-2, to=3-1]
\end{tikzcd}\]
    Therefore, these morphisms form a cone.
    Given any cone \( (A, (\mu_j)_{j \in \ob J}) \) over \( D \), we have a unique \( \mu : A \to P \) with \( \pi_j \mu = \mu_j \) for all \( j \).
    Then,
    \[ \pi_\alpha f \mu = \mu_{\cod \alpha} = D(\alpha) \mu_{\dom \alpha} = \pi_\alpha g \mu \]
    for all \( \alpha \), so \( \mu \) factors uniquely through \( e \).

    \emph{Part (iii).}
    We show that the hypotheses of (iii) imply those of (ii).
    If \( 1 \) is the terminal object, we form the pullback of the span
    % https://q.uiver.app/#q=WzAsMyxbMSwwLCJBIl0sWzEsMSwiMSJdLFswLDEsIkIiXSxbMCwxXSxbMiwxXV0=
\[\begin{tikzcd}
	& A \\
	B & 1
	\arrow[from=1-2, to=2-2]
	\arrow[from=2-1, to=2-2]
\end{tikzcd}\]
    This has the universal property of the product \( A \times B \), so \( \mathcal C \) has binary products and hence all finite products by induction.
    To construct the equaliser of \( f, g : A \rightrightarrows B \), we consider the pullback of
    % https://q.uiver.app/#q=WzAsMyxbMSwwLCJBIl0sWzEsMSwiQSBcXHRpbWVzIEIiXSxbMCwxLCJBIl0sWzAsMSwiKDFfQSwgZikiXSxbMiwxLCIoMV9BLCBnKSIsMl1d
\[\begin{tikzcd}
	& A \\
	A & {A \times B}
	\arrow["{(1_A, f)}", from=1-2, to=2-2]
	\arrow["{(1_A, g)}"', from=2-1, to=2-2]
\end{tikzcd}\]
    Any cone over this diagram has its two legs \( C \rightrightarrows A \) equal, so a pullback is an equaliser for \( f, g \).
\end{proof}
\begin{definition}
    A category is called \emph{complete} if it has all small limits, and \emph{cocomplete} if it has all small colimits.
\end{definition}
\begin{example}
    The categories \( \mathbf{Set}, \mathbf{Gp}, \mathbf{Top} \) are complete and cocomplete.
\end{example}

\subsection{Preservation and creation}
\begin{definition}
    Let \( G : \mathcal D \to \mathcal C \) be a functor.
    We say that \( G \)
    \begin{enumerate}
        \item \emph{preserves} limits of shape \( J \) if whenever \( D : J \to \mathcal D \) is a diagram with limit cone \( (L, (\lambda_j)_{j \in \ob J}) \), the cone \( (GL, (G\lambda_j)_{j \in \ob J}) \) is a limit for \( GD \);
        \item \emph{reflects} limits of shape \( J \) if whenever \( D : J \to \mathcal D \) is a diagram and \( (L, (\lambda_j)_{j \in \ob J}) \) is a cone such that \( (GL, (G\lambda_j)_{j \in \ob J}) \) is a limit for \( GD \), then \( (L, (\lambda_j)_{j \in \ob J}) \) is a limit for \( D \);
        \item \emph{creates} limits of shape \( J \) if whenever \( D : J \to \mathcal D \) is a diagram with limit cone \( (M, (\mu_j)_{j \in \ob J}) \) for \( GD \) in \( \mathcal C \), there exists a cone \( (L, (\lambda_j)_{j \in \ob J}) \) over \( D \) such that \( (GL, (G\lambda_j)_{j \in \ob J}) \cong (M, (\mu_j)_{j \in \ob J}) \) in \( \operatorname{Cone}(GD) \), and any such cone is a limit for \( D \).
    \end{enumerate}
\end{definition}
We typically assume in (i) that \( \mathcal D \) has all limits of shape \( J \), and we assume in (ii) and (iii) that \( \mathcal C \) has all limits of shape \( J \).
With these assumptions, \( G \) creates limits of shape \( J \) if and only if \( G \) preserves and reflects limits, and \( \mathcal D \) has all limits of shape \( J \).
\begin{corollary}
    In any of the statements of the previous lemma, we can replace both instances of `\( \mathcal C \) has' by either `\( \mathcal D \) has and \( G : \mathcal D \to \mathcal C \) preserves' or `\( \mathcal C \) has and \( G : \mathcal D \to \mathcal C \) creates'.
\end{corollary}
\begin{example}
    \begin{enumerate}
        \item The forgetful functor \( U : \mathbf{Gp} \to \mathbf{Set} \) creates all small limits.
        It does not preserve colimits, as in particular it does not preserve coproducts.
        \item The forgetful functor \( U : \mathbf{Top} \to \mathbf{Set} \) preserves all small limits and colimits, but does not reflect them, as we can retopologise the apex of a limit cone.
        \item The inclusion \( \mathbf{AbGp} \to \mathbf{Gp} \) reflects coproducts, but does not preserve them.
        A free product of two groups \( G, H \) is always nonabelian, except for the case where either \( G \) or \( H \) is the trivial group, but the coproduct of the trivial group with \( H \) is isomorphic to \( H \) in both categories.
    \end{enumerate}
\end{example}
\begin{lemma}
    Suppose \( \mathcal D \) has limits of shape \( J \).
    Then, for any \( \mathcal C \), the functor category \( [\mathcal C, \mathcal D] \) also has limits of shape \( J \), and the forgetful functor \( [\mathcal C, \mathcal D] \to \mathcal D^{\ob \mathcal C} \) creates them.
\end{lemma}
\begin{proof}
    Given a diagram \( D : J \to [\mathcal C, \mathcal D] \), we can regard it as a functor \( D : J \times \mathcal C \to \mathcal D \), so for a fixed object in \( \mathcal C \), we obtain a diagram \( D(-, A) \) of shape \( J \) in \( \mathcal D \), which has a limit \( (LA, (\lambda_{j,A})_{j \in \ob J}) \).
    Given any \( f : A \to B \) in \( \mathcal C \), the composites
    % https://q.uiver.app/#q=WzAsMyxbMCwwLCJMQSJdLFsxLDAsIkQoaixBKSJdLFsyLDAsIkQoaixCKSJdLFswLDEsIlxcbGFtYmRhX3tqLEF9Il0sWzEsMiwiRChqLGYpIl1d
\[\begin{tikzcd}
	LA & {D(j,A)} & {D(j,B)}
	\arrow["{\lambda_{j,A}}", from=1-1, to=1-2]
	\arrow["{D(j,f)}", from=1-2, to=1-3]
\end{tikzcd}\]
    form a cone over \( D(-, B) \), and so factor uniquely through its limit \( LB \).
    Thus we obtain \( Lf : LA \to LB \).
    This is functorial because \( Lf \) is unique with this property.
    This is the unique lifting of \( (LA)_{A \in \ob \mathcal C} \) to an object of \( [\mathcal C, \mathcal D] \) which makes the \( \lambda_{j,-} \) into natural transformations.
    It is a limit cone in \( [\mathcal C, \mathcal D] \): given any cone in \( [\mathcal C, \mathcal D] \) with apex \( M \) and legs \( (\mu_{j,-})_{j \in \ob J} \) over \( D \), the \( \mu_{j,A} \) form a cone over \( D(-, A) \), so we obtain a unique \( \nu_A : MA \to LA \) such that \( \lambda_{j,A} \nu_A = \mu_{j,A} \) for all \( A \).
    The \( \nu_A \) form a natural transformation \( M \to L \), because for any \( f : A \to B \) in \( \mathcal C \), the two paths \( \nu_B(Mf), (Lf)\nu_A : MA \rightrightarrows LB \) are factorisations of the same cone over \( D(-, B) \) through its limit, so must be equal.
\end{proof}
\begin{remark}
    Note that \( f : A \to B \) is monic if and only if
\[\begin{tikzcd}
	A & A \\
	A & B
	\arrow["{1_A}", from=1-1, to=1-2]
	\arrow["f", from=1-2, to=2-2]
	\arrow["{1_A}"', from=1-1, to=2-1]
	\arrow["f"', from=2-1, to=2-2]
\end{tikzcd}\]
    is a pullback square.
    Thus, if \( \mathcal D \) has pullbacks, any monomorphism in \( [\mathcal C, \mathcal D] \) is a pointwise monomorphism, because the pullback in \( [\mathcal C, \mathcal D] \) is constructed pointwise by the previous lemma.
\end{remark}

\subsection{Interaction with adjunctions}
\begin{lemma}
    Let \( G : \mathcal D \to \mathcal C \) be a functor with a left adjoint.
    Then \( G \) preserves all limits which exist in \( \mathcal D \).
\end{lemma}
\begin{proof}[Proof 1]
    In this proof, we will assume that \( \mathcal C, \mathcal D \) both have all limits of shape \( J \).
    If \( F \dashv G \), then the diagram
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJcXG1hdGhjYWwgQyJdLFsxLDAsIlxcbWF0aGNhbCBEIl0sWzAsMSwiW0osIFxcbWF0aGNhbCBDXSJdLFsxLDEsIltKLCBcXG1hdGhjYWwgRF0iXSxbMCwxLCJGIl0sWzAsMiwiXFxEZWx0YSIsMl0sWzEsMywiXFxEZWx0YSJdLFsyLDMsIltKLEZdIiwyXV0=
\[\begin{tikzcd}
	{\mathcal C} & {\mathcal D} \\
	{[J, \mathcal C]} & {[J, \mathcal D]}
	\arrow["F", from=1-1, to=1-2]
	\arrow["\Delta"', from=1-1, to=2-1]
	\arrow["\Delta", from=1-2, to=2-2]
	\arrow["{[J,F]}"', from=2-1, to=2-2]
\end{tikzcd}\]
    commutes.
    All of the functors in this diagram have right adjoints, so the diagram
    % https://q.uiver.app/#q=WzAsNCxbMSwxLCJbSiwgXFxtYXRoY2FsIERdIl0sWzEsMCwiXFxtYXRoY2FsIEQiXSxbMCwwLCJcXG1hdGhjYWwgQyJdLFswLDEsIltKLCBcXG1hdGhjYWwgQ10iXSxbMCwxLCJcXGxpbV9KIiwyXSxbMSwyLCJHIiwyXSxbMCwzLCJbSiwgR10iXSxbMywyLCJcXGxpbV9KIl1d
\[\begin{tikzcd}
	{\mathcal C} & {\mathcal D} \\
	{[J, \mathcal C]} & {[J, \mathcal D]}
	\arrow["{\lim_J}"', from=2-2, to=1-2]
	\arrow["G"', from=1-2, to=1-1]
	\arrow["{[J, G]}", from=2-2, to=2-1]
	\arrow["{\lim_J}", from=2-1, to=1-1]
\end{tikzcd}\]
    commutes up to natural isomorphism, where \( \lim_J \) sends a diagram of shape \( J \) to the apex of its limit cone.
    But this is exactly the statement that \( G \) preserves limits.
\end{proof}
\begin{proof}[Proof 2]
    In this proof, we will not assume that \( \mathcal C \) has limits of any kind, and only assume a single diagram \( D : J \to \mathcal D \) has a limit cone \( (L, (\lambda_j)_{j \in \ob J}) \) over it.
    Given any cone over \( GD \) with apex \( A \) and legs \( \mu_j : A \to GD(j) \), the legs correspond under the adjunction to morphisms \( \overline \mu_j : FA \to D(j) \), which form a cone over \( D \) by naturality of the adjunction.
    We obtain a unique factorisation \( \overline \mu : FA \to L \) with \( \lambda_j \overline \mu = \overline \mu_j \) for all \( j \), or equivalently, \( (G\lambda_j)\mu = \mu_j \), where \( \mu : A \to GL \) corresponds to \( \overline \mu \) under the adjunction.
\end{proof}
Suppose that \( \mathcal D \) has and \( G : \mathcal D \to \mathcal C \) preserves all limits.
The adjoint functor theorems say that \( G \) has a left adjoint, under various assumptions.
\begin{lemma}
    Suppose that \( \mathcal D \) has and \( G : \mathcal D \to \mathcal C \) preserves limits of shape \( J \).
    Then for any \( A \in \ob \mathcal C \), the category \( (A \downarrow G) \) has limits of shape \( J \), and the forgetful functor \( U : (A \downarrow G) \to \mathcal D \) creates them.
\end{lemma}
\begin{proof}
    Let \( D : J \to (A \downarrow G) \) be a diagram.
    We write each \( D(j) \) as \( (UD(j), f_j) \) where \( f_j : A \to GUD(j) \).
    Let \( (L, (\lambda_j)_{j \in \ob J}) \) be a limit for \( UD \) in \( \mathcal D \).
    By assumption, \( (GL, (G\lambda_j)_{j \in \ob J}) \) is a limit for \( GUD \) in \( \mathcal C \).
    But the edges of \( D \) are morphisms in \( (A \downarrow G) \), so the \( f_j \) form a cone over \( GUD \).
    Thus, we obtain a unique factorisation \( f : A \to GL \) such that \( (G\lambda_j) f = f_j \) for all \( j \).
    In other words, we have a unique lifting of \( L \) to an object \( (L, f) \) of \( (A \downarrow G) \) which makes the \( \lambda_j \) into a cone over \( D \) with apex \( (L, f) \).
    Any cone over \( D \) with apex \( (M, g) \) becomes a cone over \( UD \) with apex \( M \) by forgetting the structure map, so we get a unique \( h : M \to L \), and this becomes a morphism in \( (A \downarrow G) \) as both \( (Gh)g \) and \( f \) are factorisations through \( L \) of the same cone over \( UD \).
\end{proof}
\begin{lemma}
    Let \( \mathcal C \) be a category.
    Specifying an initial object of \( \mathcal C \) is equivalent to specifying a limit for the identity functor \( 1_{\mathcal C} : \mathcal C \to \mathcal C \), considered as a diagram of shape \( \mathcal C \) in \( \mathcal C \).
\end{lemma}
\begin{proof}
    First, suppose we have an initial object \( I \) in \( \mathcal C \).
    Then the unique morphisms \( I \to A \) form a cone over \( 1_{\mathcal C} \), and it is a limit, because for any other cone \( (B, (\lambda_A : B \to A)) \), then \( \lambda_I \) is the unique factorisation as required.
    Conversely, suppose \( (I, (\lambda_A : I \to A)) \) is a limit for \( 1_{\mathcal C} \).
    Then certainly \( I \) is \emph{weakly initial}: it has at least one morphism to any other object, given by \( \lambda_A \).
    For any morphism \( f : I \to A \), it is an edge of the diagram, so \( f \lambda_I = \lambda_A \), so it suffices to show that \( \lambda_I \) is the identity morphism.
    Using the same equation with \( f = \lambda_A \), we obtain \( \lambda_A \lambda_I = \lambda_A \), so \( \lambda_I \) is a factorisation of the limit cone through itself.
    As this factorisation must be unique, we must have \( \lambda_I = 1_I \).
\end{proof}
\begin{proposition}[primitive adjoint functor theorem]
    If \( \mathcal D \) has and \( G : \mathcal D \to \mathcal C \) preserves all limits, then \( G \) has a left adjoint.
\end{proposition}
\begin{proof}
    The categories \( (A \downarrow G) \) have all limits, and in particular they have initial objects, so \( G \) has a left adjoint.
\end{proof}

\subsection{General adjoint functor theorem}
\begin{theorem}[general adjoint functor theorem]
    Suppose \( \mathcal D \) is complete and locally small.
    Then a functor \( G : \mathcal D \to \mathcal C \) has a left adjoint if and only if \( G \) preserves small limits and satisfies the \emph{solution-set condition}: given any \( A \in \ob \mathcal C \), there is a set \( \qty{f_i : A \to GB_i}_{i \in I} \) such that every \( f : A \to GB \) factors as
    % https://q.uiver.app/#q=WzAsMyxbMCwwLCJBIl0sWzEsMCwiR0JfaSJdLFsyLDAsIkdCIl0sWzAsMSwiZl9pIl0sWzEsMiwiR2ciXV0=
\[\begin{tikzcd}
	A & {GB_i} & GB
	\arrow["{f_i}", from=1-1, to=1-2]
	\arrow["Gg", from=1-2, to=1-3]
\end{tikzcd}\]
    for some \( i \in I \) and \( g : B_i \to B \).
    This set \( I \) is called a solution-set at \( A \).
\end{theorem}
\begin{proof}
    If \( F \dashv G \), then \( G \) preserves all limits that exist in its domain, so in particular it preserves small limits, and \( \qty{\eta_A : A \to GFA} \) is a solution-set at \( A \) for any \( A \).
    Now suppose \( A \in \ob \mathcal C \).
    Then \( (A \downarrow G) \) is complete, and is locally small as morphisms \( (B, f) \to (B', f') \) in \( (A \downarrow G) \) are a subset of \( \mathcal D(B, B') \).
    We must then show that if \( \mathcal A \) is complete and locally small and has a weakly initial set of objects \( \qty{S_i \mid i \in I} \), then it has an initial object; then, setting \( \mathcal A = (A \downarrow G) \) and using the solution-set as the weakly initial set, the result follows.

    First, we form the product \( P = \prod_{i \in I} S_i \).
    The set \( \qty{P} \) is weakly initial since we have morphisms \( \pi_i : P \to S_i \) for all \( i \).
    Now consider the diagram \( P \rightrightarrows P \) whose edges are all endomorphisms of \( P \).
    By assumption, let \( i : I \to P \) be a limit for this diagram; this is an equaliser over a family of morphisms.
    Then \( I \) is weakly initial.
    For a parallel pair \( f, g : I \rightrightarrows C \), we have an equaliser \( e : E \to I \), and can choose some \( h : P \to E \).
    Then we have the endomorphisms \( ieh \) and \( 1_P \) of \( P \).
    Thus \( iehi = 1_P i = i \), but \( i \) is monic, so \( ehi = 1_I \).
    Hence \( e \) is a split epimorphism, and hence \( f = g \).
\end{proof}
\begin{example}
    \begin{enumerate}
        \item Consider the forgetful functor \( U : \mathbf{Gp} \to \mathbf{Set} \).
        Note that \( \mathbf{Gp} \) is complete and locally small, and \( U \) creates small limits so in particular it preserves them.
        Given a set \( A \), any function \( f : A \to UG \) can be factored as
        % https://q.uiver.app/#q=WzAsMyxbMCwwLCJBIl0sWzEsMCwiVUcnIl0sWzIsMCwiVUciXSxbMCwxXSxbMSwyXV0=
\[\begin{tikzcd}
	A & {UG'} & UG
	\arrow[from=1-1, to=1-2]
	\arrow[from=1-2, to=1-3]
\end{tikzcd}\]
        where \( G' \) is the subgroup generated by \( \qty{f(a) \mid a \in A} \).
        Note that the cardinality of \( G' \) is at most \( \max(\aleph_0, \abs{A}) \), so we can fix a set \( B \) of this cardinality and consider all possible subsets of \( B \), all possible group structures on those sets, and all possible functions \( A \to B' \); these form a solution-set at \( A \).
        Hence, free groups exist.
        Note that the cardinality bound on \( G' \) requires most of the technology needed to explicitly construct free groups.
        \item Let \( \mathbf{CLat} \) be the category of complete lattices.
        The forgetful functor \( U : \mathbf{CLat} \to \mathbf{Set} \) creates all small limits; this can be seen in the same way as was shown with the forgetful functor \( \mathbf{Gp} \to \mathbf{Set} \).
        In 1964, A.\ Hales proved that there are arbitrarily large complete lattices with only three generators.
        Hence \( U \) has no solution set at \( A = \qty{a, b, c} \).
        Note that \( U \) is representable, or equivalently, \( (1 \downarrow U) \) has an initial object.
        If \( \mathbf{CLat} \) had all coproducts, we would be able to form initial objects for \( (A \downarrow U) \), as every set is a coproduct of singletons.
        But \( \mathbf{CLat} \) does not have even finite coproducts.
    \end{enumerate}
\end{example}

\subsection{Well-poweredness}
\begin{definition}
    Let \( A \in \ob \mathcal C \).
    A \emph{subobject} of \( A \) is a monomorphism with codomain \( A \); dually, a \emph{quotient} of \( A \) is an epimorphism with domain \( A \).
    The subobjects of \( A \) in \( \mathcal C \) form a preorder \( \operatorname{Sub}_{\mathcal C}(A) \) by setting \( m \leq m' \) when \( m \) factors through \( m' \).
    \( \mathcal C \) is \emph{well-powered} if \( \operatorname{Sub}_{\mathcal C}(A) \) is equivalent to a (small) poset for any \( A \).
    Dually, we say \( \mathcal C \) is \emph{well-copowered}.
\end{definition}
\begin{example}
    \( \mathbf{Set} \) is well-powered, since every monomorphism is isomorphic to a subset inclusion; the power-set axiom encodes this fact.
    \( \mathbf{Set} \) is also well-copowered, because quotients correspond to equivalence relations up to isomorphism, there is only a set of equivalence relations on a given object \( A \).
\end{example}
\begin{lemma}
    Let
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJQIl0sWzEsMCwiQSJdLFsxLDEsIkMiXSxbMCwxLCJCIl0sWzAsMSwiaCJdLFsxLDIsImYiLDAseyJzdHlsZSI6eyJ0YWlsIjp7Im5hbWUiOiJob29rIiwic2lkZSI6InRvcCJ9fX1dLFswLDMsImsiLDJdLFszLDIsImciLDJdXQ==
\[\begin{tikzcd}
	P & A \\
	B & C
	\arrow["h", from=1-1, to=1-2]
	\arrow["f", tail, from=1-2, to=2-2]
	\arrow["k"', from=1-1, to=2-1]
	\arrow["g"', from=2-1, to=2-2]
\end{tikzcd}\]
    be a pullback square where \( f \) is monic.
    Then \( k \) is also monic.
\end{lemma}
Informally, monomorphisms are stable under pullback.
\begin{proof}
    Let \( \ell, m : D \rightrightarrows P \) be such that \( k\ell = km \).
    Then \( fhl = gk\ell = gkm = fhm \), but \( f \) is a monomorphism, so \( hl = hm \).
    % https://q.uiver.app/#q=WzAsNSxbMSwxLCJQIl0sWzIsMSwiQSJdLFsyLDIsIkMiXSxbMSwyLCJCIl0sWzAsMCwiRCJdLFswLDEsImgiXSxbMSwyLCJmIiwwLHsic3R5bGUiOnsidGFpbCI6eyJuYW1lIjoiaG9vayIsInNpZGUiOiJ0b3AifX19XSxbMCwzLCJrIiwyXSxbMywyLCJnIiwyXSxbNCwwLCJcXGVsbCIsMCx7Im9mZnNldCI6LTJ9XSxbNCwwLCJtIiwyLHsib2Zmc2V0IjoyfV1d
\[\begin{tikzcd}
	D \\
	& P & A \\
	& B & C
	\arrow["h", from=2-2, to=2-3]
	\arrow["f", tail, from=2-3, to=3-3]
	\arrow["k"', from=2-2, to=3-2]
	\arrow["g"', from=3-2, to=3-3]
	\arrow["\ell", shift left=2, from=1-1, to=2-2]
	\arrow["m"', shift right=2, from=1-1, to=2-2]
\end{tikzcd}\]
    So \( \ell \) and \( m \) are both factorisations of \( (h\ell, k\ell) \) through the pullback, so \( \ell = m \).
\end{proof}

\subsection{Special adjoint functor theorem}
\begin{theorem}
    Let \( \mathcal C, \mathcal D \) be locally small, and suppose that \( \mathcal D \) is complete, well-powered, and has a coseparating set.
    Then a functor \( G : \mathcal D \to \mathcal C \) preserves all small limits if and only if it has a left adjoint.
\end{theorem}
\begin{proof}
    As above, any functor with a left adjoint preserves all limits that exist.
    For the other direction, fix an object \( A \) and consider the category \( (A \downarrow G) \), which is complete and locally small.
    Note that the forgetful functor \( (A \downarrow G) \to \mathcal D \) preserves monomorphisms, because it preserves pullbacks.
    Thus, one can show that \( (A \downarrow G) \) is well-powered, because the subobjects of a given object \( (B, f) \) are the monomorphisms \( m : B' \to B \) for which \( f \) factors through \( Gm \).
    If \( \qty{S_i}_{i \in I} \) is a coseparating set for \( \mathcal D \), we have a coseparating set for \( (A \downarrow G) \) by taking the set of all \( f : A \to GS_i \) with \( i \in I \); this is a set by local smallness.
    This is coseparating, because given \( h, k : (B, g) \rightrightarrows (B', g') \) with \( h \neq k \), there is a morphism \( \ell : B' \to S_i \) with \( \ell h \neq \ell k \), and \( \ell \) is a morphism \( (B', g') \to (S_i, (G\ell)g') \) in \( (A \downarrow G) \).

    It remains to show that there is an initial object in a category \( \mathcal A \) if it is complete, locally small, well-powered, and has a coseparating set \( \qty{S_i}_{i \in I} \).
    First, we form the product
    \[ P = \prod_{i \in I} S_i \]
    and consider the diagram
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJcXGJ1bGxldCJdLFsxLDEsIlAiXSxbMSwwLCJcXGNkb3RzIl0sWzIsMCwiXFxidWxsZXQiXSxbMCwxXSxbMywxXV0=
\[\begin{tikzcd}
	\bullet & \cdots & \bullet \\
	& P
	\arrow[from=1-1, to=2-2]
	\arrow[from=1-3, to=2-2]
\end{tikzcd}\]
    whose edges are representative monomorphisms for each isomorphism class of subobjects of \( P \).
    Let \( I \) be the apex of a limit cone for this `wide pullback'.
    The legs of the cone are monomorphisms, using the same argument as was described for pullbacks.
    In particular, the composite maps \( I \to P \) are monomorphisms, so \( I \) is a subobject of \( P \).
    But by construction, it factors through every subobject of \( P \), so is a minimal subobject of \( P \).

    It remains to show that \( I \) is initial.
    Note that if \( f, g : I \rightrightarrows A \) were different monomorphisms, their equaliser \( e : E \to I \) would yield a subobject of \( P \) contained in \( I \to P \), so it would be an isomorphism, giving \( f = g \).
    For an arbitrary object \( A \in \ob \mathcal A \), form the product
    \[ Q = \prod_{(i,f)} S_i;\quad f : A \to S_i \]
    and define \( g : A \to Q \) by
    \[ \pi_{(i,f)} g = f \]
    As the \( S_i \) form a coseparating family, \( g \) is a monomorphism.
    Thus \( A \) is a subobject of \( Q \) by \( g \).
    There is a map \( h : P \to Q \) defined by
    \[ \pi_{(i,f)} h = \pi_i \]
    Thus we can form the pullback
    % https://q.uiver.app/#q=WzAsNCxbMCwwLCJCIl0sWzEsMCwiQSJdLFsxLDEsIlEiXSxbMCwxLCJQIl0sWzAsMV0sWzEsMiwiZyIsMCx7InN0eWxlIjp7InRhaWwiOnsibmFtZSI6Im1vbm8ifX19XSxbMCwzLCJrIiwyLHsic3R5bGUiOnsidGFpbCI6eyJuYW1lIjoibW9ubyJ9fX1dLFszLDIsImgiLDIseyJzdHlsZSI6eyJ0YWlsIjp7Im5hbWUiOiJtb25vIn19fV1d
\[\begin{tikzcd}
	B & A \\
	P & Q
	\arrow[from=1-1, to=1-2]
	\arrow["g", tail, from=1-2, to=2-2]
	\arrow["k"', tail, from=1-1, to=2-1]
	\arrow["h"', tail, from=2-1, to=2-2]
\end{tikzcd}\]
    where \( k \) is a monomorphism as it is the pullback of a monomorphism.
    Hence \( B \) is a subobject of \( P \), and thus factors through \( I \).
    % https://q.uiver.app/#q=WzAsMyxbMCwwLCJJIl0sWzEsMCwiQiJdLFsxLDEsIlAiXSxbMCwxLCIiLDAseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJkYXNoZWQifX19XSxbMSwyLCJrIl0sWzAsMl1d
\[\begin{tikzcd}
	I & B \\
	& P
	\arrow[dashed, from=1-1, to=1-2]
	\arrow["k", from=1-2, to=2-2]
	\arrow[from=1-1, to=2-2]
\end{tikzcd}\]
    Hence, we have a morphism \( I \to A \) by composition.
\end{proof}
\begin{example}
    Let \( I : \mathbf{KHaus} \to \mathbf{Top} \) be the inclusion functor.
    \( \mathbf{KHaus} \) is closed under small products in \( \mathbf{Top} \) by Tychonoff's theorem, and is closed under equalisers since the equaliser of \( f, g : X \rightrightarrows Y \) is a closed subspace of \( X \), and thus is compact and Hausdorff.
    Hence \( \mathbf{KHaus} \) is complete, and the inclusion preserves small limits.
    It is clearly locally small and well-powered, since the subobjects of \( X \) are isomorphic to closed subspaces.
    It has a single coseparator, namely \( [0,1] \), by Urysohn's lemma.
    Hence, by the special adjoint functor theorem, \( I \) has a left adjoint \( \beta \), which is the Stone--\v{C}ech compactification functor.
\end{example}
\begin{remark}
    \v{C}ech's construction of \( \beta \) is almost identical to the construction of left adjoints given above.
    Given a space \( X \), one can form
    \[ P = \prod_{f : X \to [0,1]} [0,1];\quad g : X \to P;\quad \pi_f g = f \]
    which is the product of the members of coseparating set for \( (X \downarrow I) \).
    Then, \( \beta X \) can be defined to be the closure of the image of \( g \), that is, the smallest subobject of \( (P, g) \) in \( (X \downarrow I) \).

    The general adjoint functor theorem can also be used to construct \( \beta \).
    To obtain a solution-set at a space \( X \), observe that any morphism from \( X \) to a compact Hausdorff space \( IY \) factors as \( X \to IY' \to IY \) where \( Y' \) is the closure of \( X' = \qty{f(x) \mid x \in X} \).
    One can show that if \( Y' \) is Hausdorff and \( X' \) is dense in \( Y' \), then \( \abs{Y'} \leq 2^{2^{\abs{X'}}} \).
\end{remark}
